#include<stdio.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<errno.h>
#include<stdlib.h>
int main()
{
    pid_t id=fork();
    if(id==0)
    {
        printf("i am child process\n");
        sleep(5);
        exit(0);
    }
    int status=0;
    pid_t p = waitpid(id,&status,0);
    if(p>0)
    {
        if(WIFEXITED(status))
        {
            printf("exit code:%d,exit sigal:%d\n",WEXITSTATUS(status),status&0xF);
        }
        else
        {
            printf("程序异常退出\n");
        }
    }
    else
    {
        printf("wait fail\n");
    }
    return 0;
}

